﻿@model Cxuu.Models.ViewArticleExamine
@{
    ViewData["Title"] = await SystemConfig.GetByFieldNameAsync("SiteName");
}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>@ViewData["Title"]</title>
    <link rel="stylesheet" href="~/lib/layui/css/layui.css">
    <link rel="stylesheet" href="~/css/main.css">
    <style>
        html { zoom: 100%; width: 95%; margin: 5px auto; height: auto; }
        .cxuu-content-body { font-size: 16px; line-height: 30px; height: 30px; }
            .cxuu-content-body span { width: 80px; margin-left: 10px; }
    </style>
</head>
<body>
    <div class="layui-fluid" style="margin-bottom:50px;">
        <div class="layui-form">
            <form class="layui-form" action="" lay-filter="FormEdit">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>
                        <span class="layui-form-mid layui-word-aux" style="color:black !important;font-weight:bold;font-size:22px;line-height:30px;" id="title"></span>
                    </legend>
                    <div class="layui-field-box">
                        <table class="layui-table" style="text-align:center;">
                            <colgroup>
                                <col width="50">
                                <col width="180">
                                <col width="180">
                                <col width="100">
                                <col width="80">
                                <col width="80">
                                <col width="180">
                                <col>
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>序</th>
                                    <th style="text-align:center;">报审人</th>
                                    <th style="text-align:center;">报审时间</th>
                                    <th style="text-align:center;">审核人</th>
                                    <th style="text-align:center;">状态</th>
                                    <th style="text-align:center;">通过</th>
                                    <th style="text-align:center;">审核时间</th>
                                    <th style="text-align:center;">审核意见</th>
                                </tr>
                            </thead>
                            <tbody id="listView">
                            </tbody>
                        </table>
                    </div>
                </fieldset>

                <script id="examineList" type="text/html">
                    {{#  layui.each(d.list, function(index, item){ }}
                    <tr>
                        <td>{{ index+1 }}</td>
                        <td>{{ item.groupname }} - {{ item.nickName }}</td>
                        <td>{{ item.insertTime }}</td>
                        <td>{{ item.examine }}</td>
                        <td>
                                {{#  if(item.status == 0){ }}
                                  <b style="color:#FF5722;">未审核</b>
                                {{#  } else if(item.status==1) { }}
                                  <b style="color:#5FB878;">已审</b>
                                {{#  } }}
                        </td>
                        <td>
                                {{#  if(item.pass == 0){ }}
                                  <b style="color:#FF5722;">未通过</b>
                                {{#  } else if(item.pass==1) { }}
                                  <b style="color:#5FB878;">通过</b>
                                {{#  } else if(item.pass==2) { }}
                                  <b style="color:#1E9FFF;">已办结</b>
                                {{#  } }}
                        </td>
                            <td>
                                {{# if(item.exaTime === "0001-01-01"){  }}
                                    {{# }else{  }}
                                   {{ item.exaTime }}
                                    {{# } }}
                                </td>
                        <td  style="text-align:left;">{{ item.remarks }}</td>
                      </tr>
                    {{#  }); }}
                    {{#  if(d.list.length === 0){ }}
                      无流转
                    {{#  } }}
                </script>
                <fieldset class="layui-elem-field layui-field-title">
                    <legend><label asp-for="Remarks" class="layui-form-label required"></label></legend>
                    <div class="layui-field-box" id="remarks">
                        <textarea name="Remarks" class="layui-textarea" placeholder="请输入审核意见" style="font-size:18px;line-height:30px;" cols="30" rows="5"></textarea>
                        <div style="margin-top:10px;">
                            <button class="layui-btn" lay-submit lay-filter="saveBtnTrue" id="saveBtnTrue"><i class="layui-icon">&#xe605;</i>通过</button>
                            <button class="layui-btn layui-btn-danger" lay-submit lay-filter="saveBtnFalse" id="saveBtnFalse"><i class="layui-icon">&#x1006;</i>不通过</button>
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" id="saveBtn"><i class="layui-icon">&#x1005;</i>办结</button>
                        </div>
                    </div>
                </fieldset>

                <fieldset class="layui-elem-field">
                    <legend><label asp-for="Content" class="layui-form-label required"></label></legend>
                    <div class="layui-field-box">
                        <div id="content"></div>
                    </div>
                </fieldset>

                <input asp-for="Id" type="hidden">
            </form>
        </div>
    </div>
    <script src="~/lib/jquery.min.js?v=1.12.4"></script>
    <script src="~/lib/layui/layui.js"></script>
    <script src="~/lib/cxuu-main.js"></script>
    <script>
        layui.define(function () {
            var form = layui.form, layer = layui.layer, $ = layui.jquery, upload = layui.upload, element = layui.element, laytpl = layui.laytpl;
            var laydate = layui.laydate;
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            form.render();

            let id = getUrlParam('id');
            $.getJSON("/Admin/Examine/GetExamineById", { "id": id }, function (res) {
                if (res.status == 1) {
                    var data = res.data;
                    var art = res.art;

                    form.val('FormEdit', {
                        Id: data.id,
                        Remarks: data.remarks,
                    });
                    //console.log(form.val('FormEdit'));
                    $('#title').html(art.title);
                    $('#content').html(art.content);

                    if (data.pass == 2) {
                        $('#remarks').html('<b style="color:red;">已经办结，审核流程已经终止</b>');
                    }

                    var list = res.list;
                    // 流转列表模板渲染
                    if (list !== null) {
                        var data = {
                            "list": list
                        }
                        var getTpl = examineList.innerHTML, view = document.getElementById('listView');
                        laytpl(getTpl).render(data, function (html) {
                            view.innerHTML = html;
                        });
                    }

                } else {
                    layer.msg("数据加载失败");
                }
            });


            //提交部分

            var dataPost = function (url, data) {
                $.post(url, data, function (res) {
                    if (res.status == 1) {
                        layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
                            parent.layui.table.reloadData('tableReload');
                            parent.layer.close(index); //再执行关闭
                            parent.refExamineCount();
                        });
                    } else
                        layer.msg(res.msg, { icon: 2, anim: 6, time: 5000 });
                });
            }

            //审核通过
            $('#saveBtnTrue').click(function () {
                var field = form.val('FormEdit');
                var post = {
                    Id: field.Id,
                    Remarks: field.Remarks,
                    Pass: 1,
                };
                dataPost('EditPost', post);
                return false;
            });
            //审核不通过
            $('#saveBtnFalse').click(function () {
                var field = form.val('FormEdit');
                var post = {
                    Id: field.Id,
                    Remarks: field.Remarks,
                    Pass: 0,
                };
                dataPost('EditPost', post);
                return false;
            });

            //办结
            $('#saveBtn').click(function () {
                layer.msg('办结确认？ 办结后审核流程将终止！', {
                    time: 0 //不自动关闭
                    , btn: ['确定', '关闭']
                    , yes: function (passindex) {
                        var field = form.val('FormEdit');
                        var post = {
                            Id: field.Id,
                            Remarks: field.Remarks,
                            Pass: 2,
                        };
                        dataPost('EditPost', post);
                        return false;
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>